import {Router} from "express";
import authRouters from "./authRouters";
import dictRouters from "@src/routes/back/dictRouters";
import literatureRouters from "@src/routes/back/literatureRouters";
import articleRouters from "@src/routes/back/articleRouters";
import regionRouters from "@src/routes/back/regionRouters";

// 后台路由
const backRouter = Router();

// 后台登录相关子路由
const authRouter = Router();

// 后台数据字典相关子路由
const dictRouter = Router();

// 后台文献相关子路由
const literatureRouter = Router();

// 后台文章相关子路由
const articleRouter = Router();

// 后台区域子路由
const regionRouter = Router();

// 登录处理器
authRouter.post(
  authRouters.paths.login,
  //登录路由
  authRouters.login,
);

// 添加用户处理器
authRouter.post(
  authRouters.paths.add,
  //添加用户路由
  authRouters.add,
);

// 用户信息处理器
authRouter.get(
  authRouters.paths.info,
  authRouters.info,
);

// 更新用户处理器
authRouter.put(
  authRouters.paths.update,
  authRouters.update,
);

//删除用户处理器
authRouter.delete(
  authRouters.paths.delete,
  authRouters._delete,
);

// 用户列表处理器
authRouter.get(
  authRouters.paths.userList,
  authRouters.list,
);

// 权限列表
authRouter.get(
  authRouters.paths.jurisdiction,
  authRouters.jurisdictionList,
);

backRouter.use("/", dictRouter);

//字典分类
authRouter.get(
  authRouters.paths.categoryList,
  authRouters.categoryList,
);

// 后台登录中间件
backRouter.use("/", authRouter);

// 添加数据字典
dictRouter.post(
  dictRouters.paths.add,
  dictRouters.add,
);

// 修改数据字典
dictRouter.put(
  dictRouters.paths.update,
  dictRouters.update,
);

// 待联合查询
// 刪除字典
dictRouter.delete(
  dictRouters.paths.delete,
  dictRouters._delete,
);

// 字典列表
dictRouter.get(
  dictRouters.paths.list,
  dictRouters.list,
);

// 字典下查分类
dictRouter.get(
  dictRouters.paths.category,
  dictRouters.category,
);

backRouter.use("/", literatureRouter);

// 添加文献
literatureRouter.post(
  literatureRouters.paths.add,
  literatureRouters.add,
);

// 删除文献
literatureRouter.delete(
  literatureRouters.paths.delete,
  literatureRouters._delete,
);

// 编辑文献
literatureRouter.put(
  literatureRouters.paths.update,
  literatureRouters.update,
);

// 文献列表
literatureRouter.get(
  literatureRouters.paths.list,
  literatureRouters.list,
);

// 更新首页推荐
literatureRouter.put(
  literatureRouters.paths.updateRecommend,
  literatureRouters.updateRecommend,
);

// 更新是否上架
literatureRouter.put(
  literatureRouters.paths.updateGrounding,
  literatureRouters.updateGrounding,
);

// 文献详情
literatureRouter.get(
  literatureRouters.paths.detail,
  literatureRouters.detail,
);

// 文獻排名
literatureRouter.get(
  literatureRouters.paths.ranking,
  literatureRouters.ranking,
);
backRouter.use("/", articleRouter);

// 添加文章
articleRouter.post(
  articleRouters.paths.add,
  articleRouters.add,
);

// 刪除文章
articleRouter.delete(
  articleRouters.paths.delete,
  articleRouters._delete,
);

// 更新文章
articleRouter.put(
  articleRouters.paths.update,
  articleRouters.update,
);

// 文章列表
articleRouter.get(
  articleRouters.paths.list,
  articleRouters.list,
);

// 更新推荐
articleRouter.put(
  articleRouters.paths.recommend,
  articleRouters.updateRecommend,
);

// 更新上架
articleRouter.put(
  articleRouters.paths.grounding,
  articleRouters.updateGrounding,
);

// 文章详情
articleRouter.get(
  articleRouters.paths.detail,
  articleRouters.detail,
);

// 文章排名
articleRouter.get(
  articleRouters.paths.ranking,
  articleRouters.ranking,
);

// 区域子路由
backRouter.use("/", regionRouter);

// 更新区域视频和图片文献
regionRouter.put(
  regionRouters.paths.update,
  regionRouters.update,
);

// 添加文献关联
regionRouter.post(
  regionRouters.paths.relationLiterature,
  regionRouters.relationLiterature,
);

// 添加文章关联
regionRouter.post(
  regionRouters.paths.relationArticle,
  regionRouters.relationArticle,
);

// 取消文献关联
regionRouter.put(
  regionRouters.paths.cancelRelationLiterature,
  regionRouters.cancelRelationLiterature,
);

// 取消文章关联
regionRouter.put(
  regionRouters.paths.cancelRelationArticle,
  regionRouters.cancelRelationArticle,
);

// 区域详情
regionRouter.get(
  regionRouters.paths.detail,
  regionRouters.detail,
);

// 区域关联文章列表
regionRouter.get(
  regionRouters.paths.relationArticleList,
  regionRouters.relationArticleList,
);

// 区域关联文献列表
regionRouter.get(
  regionRouters.paths.relationLiteratureList,
  regionRouters.relationLiteratureList,
);

// 区域排名
regionRouter.get(
  regionRouters.paths.ranking,
  regionRouters.ranking,
);

export default backRouter;

